package pl.edu.agh.mgr.hotel.entities;


import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Entity
@Table(name = "service_description")
public class ServiceDescription {

	@Id
	@GeneratedValue
	@NotNull
	private long id;

	@Size(max = 100)
	private String name;

	@ManyToOne
	private Country country;

	@ManyToOne
	private Province province;

	@ManyToOne
	private City city;

	@ManyToOne
	private Street street;

	@Size(max = 20)
	private String address;

	@ManyToOne
	private HotelType hotelType;

    @ManyToMany(cascade = CascadeType.ALL)
	private Set<RoomType> roomTypes;

	@Size(max = 100)
	private String wsAddress;

	@Size(max = 100)
	private String wsName;

	@NotNull
	private int dataLevel;	
	
	@NotNull
	private Date lastModifiedDate;
	
	public ServiceDescription() {
	}

	public ServiceDescription(String wsAddress) {
		this.wsAddress = wsAddress;
	}
	
	public ServiceDescription(String name, Country country,
			Province province, City city, Street street, String address,
			HotelType hotelType, Set<RoomType> roomTypes, String wsAddress,
			String wsName, int dataLevel, Date lastModifiedDate) {
		super();
		this.name = name;
		this.country = country;
		this.province = province;
		this.city = city;
		this.street = street;
		this.address = address;
		this.hotelType = hotelType;
		this.roomTypes = roomTypes;
		this.wsAddress = wsAddress;
		this.wsName = wsName;
		this.dataLevel = dataLevel;
		this.lastModifiedDate = lastModifiedDate;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Country getCountry() {
		return country;
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	public Province getProvince() {
		return province;
	}

	public void setProvince(Province province) {
		this.province = province;
	}

	public City getCity() {
		return city;
	}

	public void setCity(City city) {
		this.city = city;
	}

	public Street getStreet() {
		return street;
	}

	public void setStreet(Street street) {
		this.street = street;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public HotelType getHotelType() {
		return hotelType;
	}

	public void setHotelType(HotelType hotelType) {
		this.hotelType = hotelType;
	}

	public Set<RoomType> getRoomTypes() {
		return roomTypes;
	}

	public void setRoomTypes(Set<RoomType> roomTypes) {
		this.roomTypes = roomTypes;
	}

	public String getWsAddress() {
		return wsAddress;
	}

	public void setWsAddress(String wsAddress) {
		this.wsAddress = wsAddress;
	}

	public String getWsName() {
		return wsName;
	}

	public void setWsName(String wsName) {
		this.wsName = wsName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((wsAddress == null) ? 0 : wsAddress.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ServiceDescription other = (ServiceDescription) obj;
		if (wsAddress == null) {
			if (other.wsAddress != null)
				return false;
		} else if (!wsAddress.equals(other.wsAddress))
			return false;
		return true;
	}

	
	public int getDataLevel() {
		return dataLevel;
	}

	public void setDataLevel(int dataLevel) {
		this.dataLevel = dataLevel;
	}

	public Date getLastModifiedDate() {
		return lastModifiedDate;
	}

	public void setLastModifiedDate(Date lastModifiedDate) {
		this.lastModifiedDate = lastModifiedDate;
	}
}
